<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Seek to a DirectoryIterator item</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="directoryiterator.rewind.html">« DirectoryIterator::rewind</a></li>
      <li style="float: right;"><a href="directoryiterator.tostring.html">DirectoryIterator::__toString »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="class.directoryiterator.html">DirectoryIterator</a></li>
    <li>Seek to a DirectoryIterator item</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="directoryiterator.seek" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">DirectoryIterator::seek</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.3.0, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">DirectoryIterator::seek</span> &mdash; <span class="dc-title">Seek to a DirectoryIterator item</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-directoryiterator.seek-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>DirectoryIterator::seek</strong></span>(<span class="methodparam"><span class="type">int</span> <code class="parameter">$offset</code></span>): <span class="type"><span class="type void">void</span></span></div>


  <p class="para rdfs-comment">
   Seek to a given position in the <span class="classname"><a href="class.directoryiterator.html" class="classname">DirectoryIterator</a></span>.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-directoryiterator.seek-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>
    
     <dt>
<code class="parameter">offset</code></dt>

     <dd>

      <p class="para">
       The zero-based numeric position to seek to.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-directoryiterator.seek-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   没有返回值。
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-directoryiterator.seek-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-3616">
    <p><strong>示例 #1 <span class="methodname"><strong>DirectoryIterator::seek()</strong></span> example</strong></p>
    <div class="example-contents"><p>
     Seek to the fourth item in the directory containing the script. 
     The first two are usually <code class="literal">.</code> and <code class="literal">..</code>
    </p></div>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$iterator&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">DirectoryIterator</span><span style="color: #007700">(</span><span style="color: #0000BB">dirname</span><span style="color: #007700">(</span><span style="color: #0000BB">__FILE__</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">$iterator</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">seek</span><span style="color: #007700">(</span><span style="color: #0000BB">3</span><span style="color: #007700">);<br />if&nbsp;(</span><span style="color: #0000BB">$iterator</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">valid</span><span style="color: #007700">())&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #0000BB">$iterator</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getFilename</span><span style="color: #007700">();<br />}&nbsp;else&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">'No&nbsp;file&nbsp;at&nbsp;position&nbsp;3'</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>
  </p>
 </div>

 
 <div class="refsect1 seealso" id="refsect1-directoryiterator.seek-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="methodname"><a href="directoryiterator.rewind.html" class="methodname" rel="rdfs-seeAlso">DirectoryIterator::rewind()</a> - Rewind the DirectoryIterator back to the start</span></li>
    <li class="member"><span class="methodname"><a href="directoryiterator.next.html" class="methodname" rel="rdfs-seeAlso">DirectoryIterator::next()</a> - Move forward to next DirectoryIterator item</span></li>
    <li class="member"><span class="methodname"><a href="seekableiterator.seek.html" class="methodname" rel="rdfs-seeAlso">SeekableIterator::seek()</a> - Seeks to a position</span></li>
   </ul>
  </p>
 </div>


</div></div></div></body></html>